package com.ruoyi.info.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.info.domain.VinfoCountOrder;
import com.ruoyi.info.domain.vo.VinfoCountDaily;
import com.ruoyi.info.domain.vo.VinfoCountMonth;
import com.ruoyi.info.domain.vo.VinfoCountOrderVo;
import com.ruoyi.info.mapper.VinfoCountOrderMapper;
import com.ruoyi.info.service.IVinfoCountOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class VinfoCountOrderServiceImpl implements IVinfoCountOrderService {

    @Resource
    VinfoCountOrderMapper vinfoCountOrderMapper;

    @Override
    public VinfoCountOrderVo selectList(VinfoCountOrderVo vinfoCountOrderVo) {
        vinfoCountOrderVo.setStart((long) (vinfoCountOrderVo.getPageNumber() - 1) * vinfoCountOrderVo.getPageSize());
        vinfoCountOrderVo.setTotal(vinfoCountOrderMapper.selectTotal(vinfoCountOrderVo));
        vinfoCountOrderVo.setList(vinfoCountOrderMapper.selectList(vinfoCountOrderVo));
        System.out.println(vinfoCountOrderVo);
        return vinfoCountOrderVo;
    }

    @Override
    public void insert(List<VinfoCountOrder> vinfoCountOrderList) {
        vinfoCountOrderMapper.insert(vinfoCountOrderList);
    }

    @Override
    public void delete(Date beginTime,Date endTime,String carNo) {
        vinfoCountOrderMapper.delete(beginTime,endTime,carNo);
    }

    @Override
    public List<VinfoCountOrder> selectCountByDate(Date startTime, Date endTime, Integer page, Integer limit,List<String> list) {
        long start = (long) (page - 1) * limit;
        return vinfoCountOrderMapper.selectCountByDate(startTime,endTime,start,limit,list);
    }

    @Override
    public Long selectTotalByDate(Date startTime, Date endTime, List<String> carNoList) {
        return vinfoCountOrderMapper.selectTotalByDate(startTime,endTime,carNoList);
    }

    public List<VinfoCountMonth> selectCountMonth(Date startTime, Date endTime, Integer page, Integer limit, List<String> list) {
        long start = (long) (page - 1) * limit;
        return vinfoCountOrderMapper.selectCountMonth(startTime,endTime,start,limit,list);
    }

    public List<VinfoCountDaily> selectCountDaily(Date startTime, Date endTime, Integer page, Integer limit, List<String> list) {
        long start = (long) (page - 1) * limit;
        return vinfoCountOrderMapper.selectCountDaily(startTime,endTime,start,limit,list);
    }

}
